import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:osc/models/entity/osc_medal_entity.dart';
import 'package:osc/res/dimens.dart';
import 'package:osc/ui/pages/medal/medal_page.dart';
import 'package:osc/utils/navigator_util.dart';

import '../image_loader.dart';

class MedalListWidget extends StatelessWidget {
  final int userId;
  final int gender;
  final List<OscMedal> medals;

  const MedalListWidget({Key key, @required this.userId, @required this.gender, @required this.medals}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: Dimens.view_item_height_smaller,
      child: ListView.separated(
        scrollDirection: Axis.horizontal,
        shrinkWrap: true,
        itemBuilder: (BuildContext context, int index){
          return InkWell(
            onTap: (){
              NavigatorUtil.pushPage(context, MedalPage(userId: userId, gender: gender,));
            },
            child: Container(
              padding: EdgeInsets.symmetric(horizontal: Dimens.gap_view_smaller),
              width: Dimens.view_item_icon_height_small,
              height: Dimens.view_item_icon_height_small,
              child: ImageLoader(url: medals[index].lightLogo, fit: BoxFit.contain,),
            ),
          );
        },
        separatorBuilder: (BuildContext context, int index)=>Divider(color: Colors.transparent,),
        itemCount: medals?.length??0,
      ),
    );
  }
}
